var json;
$(function(){
	$.ajax({
		url:'Menu',//相对应的action
        type:'GET',
        dataType:'json',
        success:function(res){
        	json=res;
        	alert(JSON.stringify(json));
        	for(var i=0;i<json.length;i++){
        		var td=$('#menuItem').clone(true);
        		td.find('a').text(json[i].MENUITEMNAME);
        		td.find('a').attr('href',json[i].FUNCTIONURL+'.html');
        		$('#menuItem').after(td);
        	}
        	$('#menuItem:first').remove();
        }
	});
	
	$.ajax({
		url:'Menu_name',//相对应的action
        type:'GET',
        dataType:'json',
        success:function(res){
        	var name=$('#userName');
        	name.text(res[0].USERNAME);
        }
	});
});
function logout(){
	$.ajax({
		url:'Login_out',//相对应的action
        type:'GET',
        dataType:'json',
        success:function(res){
        	self.top.location.href="login.html";
        }
	});	
}
function tupian(idt){
    var nametu="xiaotu"+idt;
    var tp = document.getElementById(nametu);
    tp.src="./images/ico05.gif";//图片ico04为白色的正方形
	
	for(var i=1;i<30;i++)
	{
	  
	  var nametu2="xiaotu"+i;
	  if(i!=idt*1)
	  {
	    var tp2=document.getElementById('xiaotu'+i);
		if(tp2!=undefined)
	    {tp2.src="./images/ico06.gif";}//图片ico06为蓝色的正方形
	  }
	}
}

function list(idstr){
	var name1="subtree"+idstr;
	var name2="img"+idstr;
	var objectobj=document.all(name1);
	var imgobj=document.all(name2);
	
	
	//alert(imgobj);
	
	if(objectobj.style.display=="none"){
		for(i=1;i<10;i++){
			var name3="img"+i;
			var name="subtree"+i;
			var o=document.all(name);
			if(o!=undefined){
				o.style.display="none";
				var image=document.all(name3);
				image.src="./images/ico04.gif";
			}
		}
		objectobj.style.display="";
		imgobj.src="./images/ico03.gif";
	}
	else{
		objectobj.style.display="none";
		imgobj.src="./images/ico04.gif";
	}
}
